<?php namespace app\admin\controller;

use houdunwang\request\Request;
use houdunwang\route\Controller;
use system\model\Slide as SlideModel;

class Slide extends Common {
//加载中间件
	public function __construct ()
	{
		$this->auth();
	}
    //首页
    public function index(){
        //获得数据库中的数据并进行分页
		$field=SlideModel::paginate(1);
		//然后将数据进行分配到前台页面
		return view('',compact('field'));
    }
    //进行添加编辑
	public function post(){
    	$slide_id=Request::get('slide_id');
    	$model=SlideModel::find($slide_id) ? : new SlideModel();
    	if(IS_POST){
    		$model->save(Request::post());
			return $this->setRedirect('index')->success('操作成功');
		}
		return view('',compact('model'));
	}

	//进行删除
	public function remove(){
		$slide_id=Request::get('slide_id');
		$model=SlideModel::find($slide_id);
		$model->destory();
		return $this->setRedirect('index')->success('操作成功');
	}



}
